package com.sg.service.biz.pbff.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.pbff.req.*;
import com.sg.dto.biz.pbff.res.*;
import com.sg.dto.integration.app.QueryCycleConfDetailReqDto;
import com.sg.dto.integration.app.QueryCycleConfDetailRespDto;
import com.sg.service.biz.pbff.CycleConfService;
import com.wicket.okrapp.integration.CycleConfService;
import com.wicket.okrapp.integration.dto.*;
import com.wicket.okrframework.integration.InductionRecordService;
import com.wicket.okrframework.integration.dto.*;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class CycleConfServiceImpl implements CycleConfService {

    @Resource
    com.sg.service.biz.app.CycleConfService fwAppCycleConfClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;

    /**
     * B3-4新增时段规则[2549]
     * gen by moon at 8/10/2022, 3:46:37 AM
     */
    @Trace(operationName = "B3-4新增时段规则")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddCycleTimeRuleRespDto addCycleTimeRule(BffAddCycleTimeRuleReqDto reqDto) {


        AddCycleTimeRuleRespDto addCycleTimeRuleRespDto_1 = null;
//步骤0: D3-4新增时段规则 - addCycleTimeRule
        AddCycleTimeRuleRespDto addCycleTimeRuleRespDto = null;
        AddCycleTimeRuleReqDto addCycleTimeRuleReqDto = new AddCycleTimeRuleReqDto();
        if (reqDto != null) {
            addCycleTimeRuleReqDto.setTimeRuleName(reqDto.getTimeRuleName());//sourceId:79279_1
            addCycleTimeRuleReqDto.setTimeRuleCode(reqDto.getTimeRuleCode());//sourceId:79280_1
            addCycleTimeRuleReqDto.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79281_1
            addCycleTimeRuleReqDto.setStartStopType(reqDto.getStartStopType());//sourceId:79282_1
            addCycleTimeRuleReqDto.setIsContains(reqDto.getIsContains());//sourceId:79283_1
            addCycleTimeRuleReqDto.setTimeUnit(reqDto.getTimeUnit());//sourceId:79284_1
            addCycleTimeRuleReqDto.setCalculateType(reqDto.getCalculateType());//sourceId:79285_1
            addCycleTimeRuleReqDto.setTimeRelativeNumber(reqDto.getTimeRelativeNumber());//sourceId:79286_1
            addCycleTimeRuleReqDto.setTimeNumber(reqDto.getTimeNumber());//sourceId:79287_1
            addCycleTimeRuleReqDto.setFollowTimeNumber(reqDto.getFollowTimeNumber());//sourceId:79288_1
            addCycleTimeRuleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:79289_1
        }

        /*D3-4新增时段规则[2545]   */
        Assert.isNull(addCycleTimeRuleReqDto.getTimeRuleName(), "B3-4新增时段规则-D3-4新增时段规则-时段规则名称不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getTimeRuleCode(), "B3-4新增时段规则-D3-4新增时段规则-时段规则标识不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getPeriodRuleType(), "B3-4新增时段规则-D3-4新增时段规则-时段规则类型不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getStartStopType(), "B3-4新增时段规则-D3-4新增时段规则-参照哪一天不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getIsContains(), "B3-4新增时段规则-D3-4新增时段规则-是否包含参照这一天不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getTimeUnit(), "B3-4新增时段规则-D3-4新增时段规则-时间单位不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getCalculateType(), "B3-4新增时段规则-D3-4新增时段规则-计算类型不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getTimeRelativeNumber(), "B3-4新增时段规则-D3-4新增时段规则-相对周期提前或延后数量 不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getTimeNumber(), "B3-4新增时段规则-D3-4新增时段规则-时段区间数量不能为空", false);
        Assert.isNull(addCycleTimeRuleReqDto.getSubjectLifeCycle(), "B3-4新增时段规则-D3-4新增时段规则-主体生命周期不能为空", false);
        addCycleTimeRuleRespDto = fwAppCycleConfClient.addCycleTimeRule(addCycleTimeRuleReqDto).getData();

        addCycleTimeRuleRespDto_1 = addCycleTimeRuleRespDto;

        BffAddCycleTimeRuleRespDto retData = new BffAddCycleTimeRuleRespDto();
        if (addCycleTimeRuleRespDto_1 != null) {
            retData.setTimeRuleId(addCycleTimeRuleRespDto_1.getTimeRuleId());//sourceId:103458_1
        }


        return retData;
    }

    /**
     * B3-4查询时段规则列表(边界)[3072]
     * gen by moon at 8/10/2022, 3:47:09 AM
     */
    @Trace(operationName = "B3-4查询时段规则列表(边界)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCycleTimeRuleListBorderRespDto queryCycleTimeRuleListBorder(BffQueryCycleTimeRuleListBorderReqDto reqDto) {


        QueryCycleTimeRuleListRespDto queryCycleTimeRuleListRespDto_1 = null;
//步骤0: D3-4查时段规则列表 - queryCycleTimeRuleList
        QueryCycleTimeRuleListRespDto queryCycleTimeRuleListRespDto = null;
        QueryCycleTimeRuleListReqDto queryCycleTimeRuleListReqDto = new QueryCycleTimeRuleListReqDto();
        queryCycleTimeRuleListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:103379_1
        if (reqDto != null) {
            queryCycleTimeRuleListReqDto.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:103372_1
        }

        /*D3-4查时段规则列表[2547]   */
        Assert.isNull(queryCycleTimeRuleListReqDto.getPeriodRuleType(), "B3-4查询时段规则列表(边界)-D3-4查时段规则列表-时段规则类型不能为空", false);
        Assert.isNull(queryCycleTimeRuleListReqDto.getSubjectLifeCycle(), "B3-4查询时段规则列表(边界)-D3-4查时段规则列表-主体生命周期不能为空", false);
        queryCycleTimeRuleListRespDto = fwAppCycleConfClient.queryCycleTimeRuleList(queryCycleTimeRuleListReqDto).getData();

        queryCycleTimeRuleListRespDto_1 = queryCycleTimeRuleListRespDto;

        BffQueryCycleTimeRuleListBorderRespDto retData = new BffQueryCycleTimeRuleListBorderRespDto();
        if (queryCycleTimeRuleListRespDto_1 != null) {
            retData.setCycleTimeRuleList(queryCycleTimeRuleListRespDto_1.getCycleTimeRuleList().stream().map(item -> BeanUtil.toBean(item, BffCycleTimeRuleDto.class)).collect(Collectors.toList()));//sourceId:103381_1
        }


        return retData;
    }

    /**
     * B3-2查周期配置详情[2561]
     * gen by moon at 10/12/2022, 11:46:41 PM
     */
    @Trace(operationName = "B3-2查周期配置详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCycleConfDetailRespDto queryCycleConfDetail(BffQueryCycleConfDetailReqDto reqDto) {


        QueryCycleConfDetailRespDto queryCycleConfDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D3-2查周期配置详情 - queryCycleConfDetail
        QueryCycleConfDetailRespDto queryCycleConfDetailRespDto = null;
        QueryCycleConfDetailReqDto queryCycleConfDetailReqDto = new QueryCycleConfDetailReqDto();
        if (reqDto != null) {
            queryCycleConfDetailReqDto.setCycleConfId(reqDto.getCycleConfId());//SimpleFieldAssign//sourceId:79123_1
            queryCycleConfDetailReqDto.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:103369_1
        }

        /*D3-2查周期配置详情[2556]   */
        Assert.isNull(queryCycleConfDetailReqDto.getCycleConfId(), "B3-2查周期配置详情-D3-2查周期配置详情-周期配置ID不能为空", false);
        Assert.isNull(queryCycleConfDetailReqDto.getIsArchive(), "B3-2查周期配置详情-D3-2查周期配置详情-是否存档不能为空", false);
        queryCycleConfDetailRespDto = fwAppCycleConfClient.queryCycleConfDetail(queryCycleConfDetailReqDto).getData();
        Assert.isTrue(queryCycleConfDetailRespDto == null || queryCycleConfDetailRespDto.getCycleConfId() == null, "返回值不能为空", false);

        queryCycleConfDetailRespDto_1 = queryCycleConfDetailRespDto;

//步骤1: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryCycleConfDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryCycleConfDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryCycleConfDetailRespDto.getOperationInductionId());//SimpleFieldAssign//sourceId:79136_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B3-2查周期配置详情-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();


            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryCycleConfDetailRespDto retData = new BffQueryCycleConfDetailRespDto();
        if (queryCycleConfDetailRespDto_1 != null) {
            retData.setCycleConfId(queryCycleConfDetailRespDto_1.getCycleConfId());//SimpleFieldAssign//sourceId:79125_1
            retData.setCycleConfCode(queryCycleConfDetailRespDto_1.getCycleConfCode());//SimpleFieldAssign//sourceId:79126_1
            retData.setCycleTypeCode(queryCycleConfDetailRespDto_1.getCycleTypeCode());//SimpleFieldAssign//sourceId:79127_1
            retData.setCycleTypeName(queryCycleConfDetailRespDto_1.getCycleTypeName());//SimpleFieldAssign//sourceId:376550_1
            retData.setCycleConfName(queryCycleConfDetailRespDto_1.getCycleConfName());//SimpleFieldAssign//sourceId:100106_1
            retData.setSubjectLifeCycle(queryCycleConfDetailRespDto_1.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:100107_1
            retData.setFillinTimeRuleCode(queryCycleConfDetailRespDto_1.getFillinTimeRuleCode());//SimpleFieldAssign//sourceId:79128_1
            retData.setEvaTimeRuleCode(queryCycleConfDetailRespDto_1.getEvaTimeRuleCode());//SimpleFieldAssign//sourceId:79129_1
            retData.setIsWorkCycle(queryCycleConfDetailRespDto_1.getIsWorkCycle());//SimpleFieldAssign//sourceId:79130_1
            retData.setIsFillCycle(queryCycleConfDetailRespDto_1.getIsFillCycle());//SimpleFieldAssign//sourceId:79131_1
            retData.setIsEvaCycle(queryCycleConfDetailRespDto_1.getIsEvaCycle());//SimpleFieldAssign//sourceId:79132_1
            retData.setIsWarningCycle(queryCycleConfDetailRespDto_1.getIsWarningCycle());//SimpleFieldAssign//sourceId:79133_1
            retData.setIsResultCycle(queryCycleConfDetailRespDto_1.getIsResultCycle());//SimpleFieldAssign//sourceId:79134_1
            retData.setIsLastCycle(queryCycleConfDetailRespDto_1.getIsLastCycle());//SimpleFieldAssign//sourceId:79135_1
            retData.setOperateTime(queryCycleConfDetailRespDto_1.getOperateTime());//SimpleFieldAssign//sourceId:79154_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//SimpleFieldAssign//sourceId:79151_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//SimpleFieldAssign//sourceId:79152_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//SimpleFieldAssign//sourceId:79153_1
            retData.setPersonalDataId(queryInductionRecordInfoDetailComRespDto_1.getPersonalDataId());//SimpleFieldAssign//sourceId:79150_1
        }


        return retData;
    }

    /**
     * B3-2查周期配置列表（平台）[2560]
     * gen by moon at 8/17/2022, 8:04:01 PM
     */
    @Trace(operationName = "B3-2查周期配置列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCycleConfListRespDto queryCycleConfList(BffQueryCycleConfListReqDto reqDto) {


        QueryCycleConfListRespDto queryCycleConfListRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D3-2查周期配置列表 - queryCycleConfList
        QueryCycleConfListRespDto queryCycleConfListRespDto = null;
        QueryCycleConfListReqDto queryCycleConfListReqDto = new QueryCycleConfListReqDto();
        if (reqDto != null) {
            queryCycleConfListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:79093_1
        }

        /*D3-2查周期配置列表[2555]   */
        Assert.isNull(queryCycleConfListReqDto.getIsArchive(), "B3-2查周期配置列表（平台）-D3-2查周期配置列表-是否存档不能为空", false);
        queryCycleConfListRespDto = fwAppCycleConfClient.queryCycleConfList(queryCycleConfListReqDto).getData();

        queryCycleConfListRespDto_1 = queryCycleConfListRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryCycleConfListRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryCycleConfListRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryCycleConfListRespDto.getCycleConfList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));//sourceId:102252_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();

            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryCycleConfListRespDto retData = new BffQueryCycleConfListRespDto();
        //数据集融合
        if (queryCycleConfListRespDto_1 != null && !CollectionUtil.isEmpty(queryCycleConfListRespDto_1.getCycleConfList())) {
            for (CycleConfDto cycleConfDto : queryCycleConfListRespDto_1.getCycleConfList()) {
                BffCycleConfDto retElm = new BffCycleConfDto();
                if (queryCycleConfListRespDto_1 != null) {
                    retElm.setCycleConfId(cycleConfDto.getCycleConfId());//sourceId:44397_2
                    retElm.setCycleConfName(cycleConfDto.getCycleConfName());//sourceId:44399_2
                    retElm.setCycleConfCode(cycleConfDto.getCycleConfCode());//sourceId:44398_2
                    retElm.setSubjectLifeCycle(cycleConfDto.getSubjectLifeCycle());//sourceId:44400_2
                    retElm.setIsArchive(cycleConfDto.getIsArchive());//sourceId:58899_2
                    retElm.setOperateTime(cycleConfDto.getOperateTime());//sourceId:44402_2
                    retElm.setOperationInductionId(cycleConfDto.getOperationInductionId());//sourceId:44401_2
                }
                retData.getCycleConfList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(cycleConfDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//sourceId:56805_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//sourceId:56806_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//sourceId:56807_2
                            }
                        }
                    }
                }

            }
        }//sourceId:79096_1


        retData.setPageNum(queryCycleConfListRespDto.getPageNum());
        retData.setPageSize(queryCycleConfListRespDto.getPageSize());
        retData.setTotal(queryCycleConfListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryCycleConfListRespDto.getTotalNum()) / Double.valueOf(queryCycleConfListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B3-2修改周期配置[2559]
     * gen by moon at 8/10/2022, 3:46:57 AM
     */
    @Trace(operationName = "B3-2修改周期配置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateCycleConfRespDto updateCycleConf(BffUpdateCycleConfReqDto reqDto) {


        //步骤0: D3-2修改周期配置 - updateCycleConf
        UpdateCycleConfRespDto updateCycleConfRespDto = null;
        UpdateCycleConfReqDto updateCycleConfReqDto = new UpdateCycleConfReqDto();
        if (reqDto != null) {
            updateCycleConfReqDto.setCycleConfId(reqDto.getCycleConfId());//sourceId:103410_1
            updateCycleConfReqDto.setCycleConfName(reqDto.getCycleConfName());//sourceId:103411_1
            updateCycleConfReqDto.setCycleConfCode(reqDto.getCycleConfCode());//sourceId:103412_1
            updateCycleConfReqDto.setCycleTypeCode(reqDto.getCycleTypeCode());//sourceId:103413_1
            updateCycleConfReqDto.setFillinTimeRuleCode(reqDto.getFillinTimeRuleCode());//sourceId:103414_1
            updateCycleConfReqDto.setEvaTimeRuleCode(reqDto.getEvaTimeRuleCode());//sourceId:103415_1
            updateCycleConfReqDto.setIsFillCycle(reqDto.getIsFillCycle());//sourceId:103416_1
            updateCycleConfReqDto.setIsEvaCycle(reqDto.getIsEvaCycle());//sourceId:103417_1
            updateCycleConfReqDto.setIsWarningCycle(reqDto.getIsWarningCycle());//sourceId:103418_1
            updateCycleConfReqDto.setIsWorkCycle(reqDto.getIsWorkCycle());//sourceId:103419_1
            updateCycleConfReqDto.setIsLastCycle(reqDto.getIsLastCycle());//sourceId:103420_1
            updateCycleConfReqDto.setIsResultCycle(reqDto.getIsResultCycle());//sourceId:103421_1
            updateCycleConfReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:103422_1
        }

        /*D3-2修改周期配置[2554]   */
        Assert.isNull(updateCycleConfReqDto.getCycleConfId(), "B3-2修改周期配置-D3-2修改周期配置-周期配置ID不能为空", false);
        updateCycleConfRespDto = fwAppCycleConfClient.updateCycleConf(updateCycleConfReqDto).getData();


        BffUpdateCycleConfRespDto retData = new BffUpdateCycleConfRespDto();


        return retData;
    }

    /**
     * B3-2新增周期配置[2557]
     * gen by moon at 8/10/2022, 3:46:53 AM
     */
    @Trace(operationName = "B3-2新增周期配置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddCycleConfRespDto addCycleConf(BffAddCycleConfReqDto reqDto) {


        AddCycleConfRespDto addCycleConfRespDto_1 = null;
//步骤0: D3-2新增周期配置 - addCycleConf
        AddCycleConfRespDto addCycleConfRespDto = null;
        AddCycleConfReqDto addCycleConfReqDto = new AddCycleConfReqDto();
        if (reqDto != null) {
            addCycleConfReqDto.setCycleConfName(reqDto.getCycleConfName());//sourceId:114328_1
            addCycleConfReqDto.setCycleConfCode(reqDto.getCycleConfCode());//sourceId:79049_1
            addCycleConfReqDto.setCycleTypeCode(reqDto.getCycleTypeCode());//sourceId:79050_1
            addCycleConfReqDto.setFillinTimeRuleCode(reqDto.getFillinTimeRuleCode());//sourceId:79051_1
            addCycleConfReqDto.setEvaTimeRuleCode(reqDto.getEvaTimeRuleCode());//sourceId:79052_1
            addCycleConfReqDto.setIsFillCycle(reqDto.getIsFillCycle());//sourceId:79053_1
            addCycleConfReqDto.setIsEvaCycle(reqDto.getIsEvaCycle());//sourceId:79054_1
            addCycleConfReqDto.setIsWarningCycle(reqDto.getIsWarningCycle());//sourceId:79055_1
            addCycleConfReqDto.setIsWorkCycle(reqDto.getIsWorkCycle());//sourceId:79056_1
            addCycleConfReqDto.setIsLastCycle(reqDto.getIsLastCycle());//sourceId:79057_1
            addCycleConfReqDto.setIsResultCycle(reqDto.getIsResultCycle());//sourceId:79058_1
            addCycleConfReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:79059_1
        }

        /*D3-2新增周期配置[2553]   */
        Assert.isNull(addCycleConfReqDto.getCycleConfName(), "B3-2新增周期配置-D3-2新增周期配置-周期配置名称不能为空", false);
        Assert.isNull(addCycleConfReqDto.getCycleConfCode(), "B3-2新增周期配置-D3-2新增周期配置-周期配置标识不能为空", false);
        Assert.isNull(addCycleConfReqDto.getCycleTypeCode(), "B3-2新增周期配置-D3-2新增周期配置-周期类型标识不能为空", false);
        Assert.isNull(addCycleConfReqDto.getFillinTimeRuleCode(), "B3-2新增周期配置-D3-2新增周期配置-填报时段规则标识不能为空", false);
        Assert.isNull(addCycleConfReqDto.getEvaTimeRuleCode(), "B3-2新增周期配置-D3-2新增周期配置-评价时段规则标识不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsFillCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否填报周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsEvaCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否评价周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsWarningCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否预警周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsWorkCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否工作周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsLastCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否末级周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getIsResultCycle(), "B3-2新增周期配置-D3-2新增周期配置-是否结果周期不能为空", false);
        Assert.isNull(addCycleConfReqDto.getSubjectLifeCycle(), "B3-2新增周期配置-D3-2新增周期配置-主体生命周期不能为空", false);
        addCycleConfRespDto = fwAppCycleConfClient.addCycleConf(addCycleConfReqDto).getData();

        addCycleConfRespDto_1 = addCycleConfRespDto;

        BffAddCycleConfRespDto retData = new BffAddCycleConfRespDto();
        if (addCycleConfRespDto_1 != null) {
            retData.setCycleConfId(addCycleConfRespDto_1.getCycleConfId());//sourceId:103441_1
        }


        return retData;
    }

    /**
     * B3-4查时段规则详情[2552]
     * gen by moon at 8/10/2022, 3:46:49 AM
     */
    @Trace(operationName = "B3-4查时段规则详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCycleTimeRuleDetailRespDto queryCycleTimeRuleDetail(BffQueryCycleTimeRuleDetailReqDto reqDto) {


        QueryCycleTimeRuleDetailRespDto queryCycleTimeRuleDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D3-4查时段规则详情 - queryCycleTimeRuleDetail
        QueryCycleTimeRuleDetailRespDto queryCycleTimeRuleDetailRespDto = null;
        QueryCycleTimeRuleDetailReqDto queryCycleTimeRuleDetailReqDto = new QueryCycleTimeRuleDetailReqDto();
        if (reqDto != null) {
            queryCycleTimeRuleDetailReqDto.setTimeRuleId(reqDto.getTimeRuleId());//sourceId:79340_1
            queryCycleTimeRuleDetailReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:103447_1
        }

        /*D3-4查时段规则详情[2548]   */
        Assert.isNull(queryCycleTimeRuleDetailReqDto.getTimeRuleId(), "B3-4查时段规则详情-D3-4查时段规则详情-时段规则ID不能为空", false);
        Assert.isNull(queryCycleTimeRuleDetailReqDto.getIsArchive(), "B3-4查时段规则详情-D3-4查时段规则详情-是否存档不能为空", false);
        queryCycleTimeRuleDetailRespDto = fwAppCycleConfClient.queryCycleTimeRuleDetail(queryCycleTimeRuleDetailReqDto).getData();

        queryCycleTimeRuleDetailRespDto_1 = queryCycleTimeRuleDetailRespDto;

//步骤1: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryCycleTimeRuleDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryCycleTimeRuleDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryCycleTimeRuleDetailRespDto.getOperationInductionId());//sourceId:79374_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B3-4查时段规则详情-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryCycleTimeRuleDetailRespDto retData = new BffQueryCycleTimeRuleDetailRespDto();
        if (queryCycleTimeRuleDetailRespDto_1 != null) {
            retData.setTimeRuleId(queryCycleTimeRuleDetailRespDto_1.getTimeRuleId());//sourceId:79382_1
            retData.setTimeRuleCode(queryCycleTimeRuleDetailRespDto_1.getTimeRuleCode());//sourceId:79383_1
            retData.setTimeRuleName(queryCycleTimeRuleDetailRespDto_1.getTimeRuleName());//sourceId:79384_1
            retData.setTimeRelativeNumber(queryCycleTimeRuleDetailRespDto_1.getTimeRelativeNumber());//sourceId:79385_1
            retData.setTimeNumber(queryCycleTimeRuleDetailRespDto_1.getTimeNumber());//sourceId:79386_1
            retData.setFollowTimeNumber(queryCycleTimeRuleDetailRespDto_1.getFollowTimeNumber());//sourceId:79387_1
            retData.setTimeUnit(queryCycleTimeRuleDetailRespDto_1.getTimeUnit());//sourceId:79388_1
            retData.setCalculateType(queryCycleTimeRuleDetailRespDto_1.getCalculateType());//sourceId:79389_1
            retData.setStartStopType(queryCycleTimeRuleDetailRespDto_1.getStartStopType());//sourceId:79390_1
            retData.setIsContains(queryCycleTimeRuleDetailRespDto_1.getIsContains());//sourceId:79391_1
            retData.setSubjectLifeCycle(queryCycleTimeRuleDetailRespDto_1.getSubjectLifeCycle());//sourceId:79392_1
            retData.setOperationInductionId(queryCycleTimeRuleDetailRespDto_1.getOperationInductionId());//sourceId:79394_1
            retData.setOperateTime(queryCycleTimeRuleDetailRespDto_1.getOperateTime());//sourceId:79398_1
            retData.setPeriodRuleType(queryCycleTimeRuleDetailRespDto_1.getPeriodRuleType());//sourceId:173608_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:103449_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:79407_1
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:79405_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:79406_1
        }


        return retData;
    }

    /**
     * B3-4查时段规则列表（平台）[2551]
     * gen by moon at 8/10/2022, 3:46:46 AM
     */
    @Trace(operationName = "B3-4查时段规则列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCycleTimeRuleListRespDto queryCycleTimeRuleList(BffQueryCycleTimeRuleListReqDto reqDto) {


        QueryCycleTimeRuleListRespDto queryCycleTimeRuleListRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D3-4查时段规则列表 - queryCycleTimeRuleList
        QueryCycleTimeRuleListRespDto queryCycleTimeRuleListRespDto = null;
        QueryCycleTimeRuleListReqDto queryCycleTimeRuleListReqDto = new QueryCycleTimeRuleListReqDto();
        if (reqDto != null) {
            queryCycleTimeRuleListReqDto.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79324_1
            queryCycleTimeRuleListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:79325_1
        }

        /*D3-4查时段规则列表[2547]   */
        Assert.isNull(queryCycleTimeRuleListReqDto.getPeriodRuleType(), "B3-4查时段规则列表（平台）-D3-4查时段规则列表-时段规则类型不能为空", false);
        Assert.isNull(queryCycleTimeRuleListReqDto.getIsArchive(), "B3-4查时段规则列表（平台）-D3-4查时段规则列表-是否存档不能为空", false);
        queryCycleTimeRuleListRespDto = fwAppCycleConfClient.queryCycleTimeRuleList(queryCycleTimeRuleListReqDto).getData();

        queryCycleTimeRuleListRespDto_1 = queryCycleTimeRuleListRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryCycleTimeRuleListRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryCycleTimeRuleListRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryCycleTimeRuleListRespDto.getCycleTimeRuleList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));//sourceId:102319_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();

            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryCycleTimeRuleListRespDto retData = new BffQueryCycleTimeRuleListRespDto();
        //数据集融合
        if (queryCycleTimeRuleListRespDto_1 != null && !CollectionUtil.isEmpty(queryCycleTimeRuleListRespDto_1.getCycleTimeRuleList())) {
            for (CycleTimeRuleDto cycleTimeRuleDto : queryCycleTimeRuleListRespDto_1.getCycleTimeRuleList()) {
                BffCycleTimeRuleDto retElm = new BffCycleTimeRuleDto();
                if (queryCycleTimeRuleListRespDto_1 != null) {
                    retElm.setTimeRuleId(cycleTimeRuleDto.getTimeRuleId());//sourceId:44487_2
                    retElm.setTimeRuleCode(cycleTimeRuleDto.getTimeRuleCode());//sourceId:44488_2
                    retElm.setTimeRuleName(cycleTimeRuleDto.getTimeRuleName());//sourceId:44489_2
                    retElm.setSubjectLifeCycle(cycleTimeRuleDto.getSubjectLifeCycle());//sourceId:44490_2
                    retElm.setIsArchive(cycleTimeRuleDto.getIsArchive());//sourceId:58904_2
                    retElm.setOperationInductionId(cycleTimeRuleDto.getOperationInductionId());//sourceId:44491_2
                    retElm.setOperateTime(cycleTimeRuleDto.getOperateTime());//sourceId:56812_2
                }
                retData.getCycleTimeRuleList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(cycleTimeRuleDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setUserId(perOrgInductionRecordDto.getUserId());//sourceId:57207_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//sourceId:56825_2
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//sourceId:56823_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//sourceId:56824_2
                            }
                        }
                    }
                }

            }
        }//sourceId:79329_1


        retData.setPageNum(queryCycleTimeRuleListRespDto.getPageNum());
        retData.setPageSize(queryCycleTimeRuleListRespDto.getPageSize());
        retData.setTotal(queryCycleTimeRuleListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryCycleTimeRuleListRespDto.getTotalNum()) / Double.valueOf(queryCycleTimeRuleListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B3-4修改时段规则[2550]
     * gen by moon at 8/10/2022, 3:46:41 AM
     */
    @Trace(operationName = "B3-4修改时段规则")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateCycleTimeRuleRespDto updateCycleTimeRule(BffUpdateCycleTimeRuleReqDto reqDto) {


        //步骤0: D3-4修改时段规则 - updateCycleTimeRule
        UpdateCycleTimeRuleRespDto updateCycleTimeRuleRespDto = null;
        UpdateCycleTimeRuleReqDto updateCycleTimeRuleReqDto = new UpdateCycleTimeRuleReqDto();
        if (reqDto != null) {
            updateCycleTimeRuleReqDto.setTimeRuleId(reqDto.getTimeRuleId());//sourceId:103454_1
            updateCycleTimeRuleReqDto.setTimeRuleName(reqDto.getTimeRuleName());//sourceId:79302_1
            updateCycleTimeRuleReqDto.setTimeRuleCode(reqDto.getTimeRuleCode());//sourceId:79303_1
            updateCycleTimeRuleReqDto.setStartStopType(reqDto.getStartStopType());//sourceId:79304_1
            updateCycleTimeRuleReqDto.setIsContains(reqDto.getIsContains());//sourceId:79305_1
            updateCycleTimeRuleReqDto.setTimeUnit(reqDto.getTimeUnit());//sourceId:79306_1
            updateCycleTimeRuleReqDto.setCalculateType(reqDto.getCalculateType());//sourceId:79307_1
            updateCycleTimeRuleReqDto.setTimeRelativeNumber(reqDto.getTimeRelativeNumber());//sourceId:79308_1
            updateCycleTimeRuleReqDto.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79309_1
            updateCycleTimeRuleReqDto.setTimeNumber(reqDto.getTimeNumber());//sourceId:79310_1
            updateCycleTimeRuleReqDto.setFollowTimeNumber(reqDto.getFollowTimeNumber());//sourceId:79311_1
            updateCycleTimeRuleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:79312_1
        }

        /*D3-4修改时段规则[2546]   */
        Assert.isNull(updateCycleTimeRuleReqDto.getTimeRuleId(), "B3-4修改时段规则-D3-4修改时段规则-时段规则ID不能为空", false);
        updateCycleTimeRuleRespDto = fwAppCycleConfClient.updateCycleTimeRule(updateCycleTimeRuleReqDto).getData();


        BffUpdateCycleTimeRuleRespDto retData = new BffUpdateCycleTimeRuleRespDto();


        return retData;
    }
    //
}
